package fr.sportcom.sportcom.model;

import fr.sportcom.sportcom.R;
import fr.sportcom.sportcom.SportComApplication;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class AdsManager {
	public static void displayAds(Activity activity) {
		ImageView banner = (ImageView) activity.findViewById(R.id.ads_banner);
		if(banner != null) {
			SportComApplication app = (SportComApplication) (activity.getApplication());
			banner.setImageDrawable(app.getDrawAds());
			banner.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					SportComApplication appli = (SportComApplication) (v.getContext().getApplicationContext());
					Uri uri = Uri.parse(CustomHttpClient.HTTP_BASE_URL + "redirect?id=" + appli.getPubId());
	                v.getContext().startActivity(new Intent(Intent.ACTION_VIEW, uri));
				}
			});
		}
	}
}
